package com.yanqu.road.server.pb;

import com.yanqu.road.entity.activity.shuihu.ShuiHuUserData;
import com.yanqu.road.entity.activity.shuihu.config.ShuiHuCardConfig;
import com.yanqu.road.entity.activity.shuihu.config.ShuiHuCombConfig;
import com.yanqu.road.entity.activity.shuihu.config.ShuiHuConfig;
import com.yanqu.road.pb.activity.ShuiHuActivityProto;
import com.yanqu.road.server.manger.ServerLanguageMgr;
import com.yanqu.road.utils.property.PropertyHelper;

public class ShuiHuPb {

    public static ShuiHuActivityProto.SyncShuiHuConfigRespMsg.Builder parseShuiHuConfigRespMsg(ShuiHuConfig shuiHuConfig, String language) {
        ShuiHuActivityProto.SyncShuiHuConfigRespMsg.Builder builder = ShuiHuActivityProto.SyncShuiHuConfigRespMsg.newBuilder();
        for (ShuiHuCardConfig cardConfig : shuiHuConfig.getCardConfigMap().values()) {
            builder.addCardConfigList(parseShuiHuCardConfigMsg(cardConfig, language));
        }
        for (ShuiHuCombConfig combConfig : shuiHuConfig.getCombConfigMap().values()) {
            builder.addCombConfigList(parseShuiHuCombConfigMsg(combConfig, language));
        }
        builder.setDrawCost(shuiHuConfig.getDrawCost());
        builder.setNoticeMaxCount(shuiHuConfig.getNoticeMaxCount());
        builder.addAllQualityCountList(shuiHuConfig.getQualityCountList());
        builder.setBigRewardCardId(shuiHuConfig.getBigRewardCardId());
        builder.setSpecialQualityList(shuiHuConfig.getSpecialQualityList());
        return builder;
    }

    public static ShuiHuActivityProto.ShuiHuCardConfigMsg.Builder parseShuiHuCardConfigMsg(ShuiHuCardConfig shuiHuCardConfig, String language) {
        ShuiHuActivityProto.ShuiHuCardConfigMsg.Builder builder = ShuiHuActivityProto.ShuiHuCardConfigMsg.newBuilder();
        builder.setId(shuiHuCardConfig.getId());
        builder.setQuality(shuiHuCardConfig.getQuality());
        builder.setScore(shuiHuCardConfig.getScore());
        builder.setDecomposePoint(shuiHuCardConfig.getDecomposePoint());
        builder.setComposePoint(shuiHuCardConfig.getComposePoint());
        builder.setName(ServerLanguageMgr.getContent(shuiHuCardConfig.getName(), language));
        builder.setDesc(ServerLanguageMgr.getContent(shuiHuCardConfig.getDesc(), language));
        builder.setIcon(shuiHuCardConfig.getIcon());
        builder.setSort(shuiHuCardConfig.getSort());
        return builder;
    }

    public static ShuiHuActivityProto.ShuiHuCombConfigMsg.Builder parseShuiHuCombConfigMsg(ShuiHuCombConfig shuiHuCombConfig, String language) {
        ShuiHuActivityProto.ShuiHuCombConfigMsg.Builder builder = ShuiHuActivityProto.ShuiHuCombConfigMsg.newBuilder();
        builder.setId(shuiHuCombConfig.getId());
        builder.setCondition(shuiHuCombConfig.getCondition());
        builder.setReward(shuiHuCombConfig.getReward());
        builder.setMaxTimes(shuiHuCombConfig.getMaxTimes());
        builder.setName(ServerLanguageMgr.getContent(shuiHuCombConfig.getName(), language));
        builder.setSort(shuiHuCombConfig.getSort());
        return builder;
    }

    public static ShuiHuActivityProto.ShuiHuUserDataMsg.Builder parseShuiHuUserDataMsg(ShuiHuUserData userData) {
        ShuiHuActivityProto.ShuiHuUserDataMsg.Builder builder = ShuiHuActivityProto.ShuiHuUserDataMsg.newBuilder();
        builder.setScore(userData.getScore());
        builder.setPoint(userData.getPoint());
        builder.setCardList(PropertyHelper.parsePropertyToString(userData.getCardProp()));
        builder.setCombList(PropertyHelper.parsePropertyToString(userData.getCombProp()));
        builder.addAllGotCardList(userData.getGotCardIdList());
        return builder;
    }

}
